Length and Len (str) are equivalent functions. However, Length is preferred in Crystal syntax whereas Len is preferred in Basic syntax.
Length returns the number of characters in a text string that you enter into the formula, or in a text string stored as a value in a data field.
Note: Text strings must be enclosed in either double or single quotation marks (" " or ` '). Any blank spaces are included as part of the character count.
Use this function any time you have a manipulation, comparison, or calculation that is dependent on the length of a text string.
The following examples are applicable to both Basic and Crystal syntax, although Len is preferred in the latter:
Length(ToText({orders.ORDER AMOUNT}))
Returns 9, where {orders.ORDER AMOUNT} is 14233.08, and ToText ({orders.ORDER AMOUNT}) returns the String "14,233.08". Here, the comma and period have been specified in the Number format for the formula field as the thousands and decimal separators respectively,
Length(ToText({orders.ORDER AMOUNT}, 2, "", "."))
Returns 8 where {orders.ORDER AMOUNT} = 14233.08, and ToText ({orders.ORDER AMOUNT}, 2, "", ".") returns the String "14233.08". Here, the null character and period have been specified in the Number format for the formula field as the thousands and decimal separators respectively.
Returns 9. (The blank space between BOB and SMITH is counted as a character.)
Length({customer.CUSTOMER NAME})
The length of the text string stored as a value in {customer.CUSTOMER NAME}.
The following examples are applicable to Crystal syntax.
{customer.CUSTOMER NAME}[Length({customer.CUSTOMER NAME})
Returns the third character from the right in the Customer Name. This can also be used to extract a substring from a String that always starts at a fixed position from the end of the String.
In the following example, an address line contains the province name and postal code. Full province names are of different lengths, but the first character of the postal code is always the seventh from the last character. The formula determines the length of the address line, subtracts 7 from it, and uses the result to identify the first character of the postal code in the address line.
addressLine := "British Columbia V6X 3W2";
addrLength := Length (addressLine);
addressLine [addrLength
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |